﻿@using pageRes = FlashCards.WebApp.Resources.PageResources
@using groupSecurity = FlashCards.WebApp.Security.GroupsSecurityProvider
@model FlashCards.WebApp.Models.GroupFlashcardsModel
@{
    ViewBag.Title = "ViewGroupFlashcardSets";
    ViewBag.CanUserEditSets = groupSecurity.CanUserEditSets(User.Identity.Name, Model.Group.GroupId);
}
<h2>@Model.Group.Name - @pageRes.GroupFlashcardsSets</h2>
@if (Model != null)
{
    if (Model.FlashcardSets != null && Model.FlashcardSets.Count > 0)
    { 
        <div class="content-center">
            <table>
                <tr>
                    <th>
                        @pageRes.FlashcardSetName
                    </th>
                    <th>
                        @pageRes.FlashcardSetTags
                    </th>
                    <th>
                    </th>
                    <th></th>
                    @if (ViewBag.CanUserEditSets)
                    { 
                        <th>
                        </th>
                    }
                </tr>
                @foreach (var set in Model.FlashcardSets)
                {
                    <tr>
                        <td>@set.Name
                        </td>
                        <td>@set.Tags
                        </td>
                        <td>@Html.ActionLink(pageRes.ButtonRepeat, "RepeatFlashcardSet", "Flashcards", new { flashcardSetId = set.Id, userId = Model.UserId }, null)
                        </td>
                        <td>@Html.ActionLink("Zobacz postępy", "ViewFlashcardProgress", "Flashcards", new { flashcardSetId = set.Id, userId = Model.UserId }, null)
                        </td>
                        @if (ViewBag.CanUserEditSets)
                        { 
                            <td>
                                @Html.ActionLink(pageRes.ButtonEdit, "EditFlashcardSet", "Flashcards", new { flashcardSetId = set.Id, userId = Model.UserId }, null)
                            </td>
                        }
                    </tr>
                }
            </table>
        </div>
    }
    else
    {
         <p>@pageRes.GroupFlashcardsSetsEmpty</p>
    }
}

<p>
    @Html.ActionLink("Add new flashcard", "CreateFlashcardSet", "Flashcards", new { userId = Model.UserId, groupId = Model.Group.GroupId }, null) | 
    @Html.ActionLink("Add existing flashcard", "AddExistingFlashcardSetToGroup", new { groupId = Model.Group.GroupId })
</p>
